<template>
	<view style="padding: 50rpx 10rpx">
		<view class="collect_box">
			<view class="list_box">
				<view class="list_item" v-for="(item, index) in talentsList" :key="index" @click="onClick(item)" :style="'background-color:' + item.bgcolor">
					<view style="height: 150rpx; text-align: center; line-height: 150rpx; color: #fff">
						<text>{{ item.name }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getHistory } from '@/api/history.js';
export default {
	data() {
		return {
			talentsList: [],
			colors: ['cadetblue', 'darksalmon', 'darksalmon', 'cadetblue']
		};
	},
	created() {
		this.getHistoryList();
	},
	methods: {
		async getHistoryList() {
			const data = {
				type: 2
			};
			const res = await getHistory(data);
			this.talentsList = res.data;
			this.talentsList.forEach((item, index) => {
				const colorIndex = index % this.colors.length;
				this.talentsList[index].bgcolor = this.colors[colorIndex];
			});
		},
		onClick(item) {
			console.log(item);
			if (item.url.includes('113.142.144.25')) {
				console.log('不用跳转');
				if (item.name.includes('新双创队伍')) {
					uni.navigateTo({
						url: '/subpages/pages/serviceReport/kjrcReport/xscdw?id=' + item.id
					});
				}else if(item.name==='行业专家申请'){
					uni.navigateTo({
						url: '/subpages/pages/serviceReport/kjrcReport/industryExperts?id=' + item.id
					});
				} else if(item.name.includes('创新团队')){
					uni.navigateTo({
						url:'/subpages/pages/serviceReport/kcptReport/cxtdReport'
					})
				} else {
					uni.showModal({
						title: '温馨提示',
						content: '请前往电脑端完成申报，电脑端地址：http://113.142.144.25:8082',
						confirmText: '我知道了', // 确认按钮的文字
						showCancel: false, // 是否显示取消按钮，默认为 true
						confirmColor: '#007aff',
						success: (res) => {
							if (res.confirm) {
								// console.log('comfirm') //点击确定之后执行的代码
							} else {
								// console.log('cancel') //点击取消之后执行的代码
							}
						}
					});
				}
			} else {
				console.log('去省平台申报');
				uni.showModal({
					title: '温馨提示',
					content: '请前往' + item.url + '进行申报',
					confirmText: '我知道了', // 确认按钮的文字
					showCancel: false, // 是否显示取消按钮，默认为 true
					confirmColor: '#007aff',
					success: (res) => {
						if (res.confirm) {
							// console.log('comfirm') //点击确定之后执行的代码
						} else {
							// console.log('cancel') //点击取消之后执行的代码
						}
					}
				});
			}
		}
	}
};
</script>

<style scoped lang="scss">
.collect_box {
	.title {
		font-weight: 700;
		font-size: 36rpx;
		color: #333;
		line-height: 50rpx;
		text-align: center;
	}
	.list_box {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		.list_item {
			border-radius: 10rpx;
			overflow: hidden;
			margin: 10rpx 0;
			width: 48%;
			&.mask {
				position: relative;
				&::before {
					content: '';
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
					background-color: rgba(50, 50, 50, 0.5);
				}
			}
		}
	}
}
</style>
